$(document).ready(function() {
    var now=new Date();
    var day = ("0" + now.getDate()).slice(-2);
    var month = ("0" + (now.getMonth() + 1)).slice(-2);
    var MyDate = now.getFullYear()+"-"+(month)+"-"+(day);
    $("#tdate").val(MyDate);
    $("#b_add").click(function() {
        var content=$("#tquestion").val();
        if(content==""){
            return;
        }
        $.ajax({
            type:"POST",
            url:path+"/question/addContent",
            data:{
                content:content
            },
            dataType:"json",
            success:function (data) {
                if(data==null){
                    alert("添加失败！");
                }
                else{
                    $("#tquestion").val("");
                    var table=$("#table_question");
                    table.append("<tr><td>"+data.id+"</td><td>"+data.content+"</td><td><input type='button' class='b_delete' value='删除' /></td></tr>");
                    $(".b_delete").click(function() {
                        $(this).parent().parent().remove();
                    })
                }
            },
            error:function (err) {
                console.log(err);
            }
        })
    })
})